-----------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/juanpablouribetrujillo/My Drive (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analys
> is/../logs/create_national_vars.log
  log type:  text
 opened on:  24 Jun 2024, 22:26:48

. *settings some settings that are common for the set of plots on this dofile;
.  local pdf_plot_settings =      `"
>                                 xmtick(1980(1)2008)
>                                 xlabel(1980(10)2010)
>                                 ylabel(#3,)
>                                 ymticks(##4)
>                                 scale(*1.5) 
>                                 xtitle("")
>                                 legend(off)"';

. *scale(*1.3): This rescales the font size of the whole figure;
.         ********************************************************************;
.         use "../data/state_year_all_80_15.dta", clear  ;

. *---------------------------------------------------;
. * - Generate variables and general cleanings ;
. *---------------------------------------------------;
. do "_setup_expenditure.do";

. /******************************************************************
> 
> setup_expenditure.do
> 
> Subroutine to calculate expenditure variables for all analysis programs;
> 
> mt 20190506
> *******************************************************************/
. # delim ;  
delimiter now ;
. * expenditure on length and IRI from SF12a. Check that categories are right. Can we break apart ROW?;
. *conversion factor to get to 10^6 2010 dollars;
. gen deflate= 1/(ppiaco_2010*10);

. *gen deflate= 1;
. *consolidate rural and urban SF12a variables that we need;
. local rur_urb_list      "exp_eng_row_IH                 exp_row_IH              exp_eng_IH              e
> xp_new_cons_IH
>                         exp_relocation_IH               exp_recons_IH           exp_recons_add_IH       e
> xp_recons_noadd_IH
>                         exp_maj_wide_IH                 exp_R3_IH               exp_R3_min_wide_IH      e
> xp_R3_rehab_rest_IH    
>                         exp_R3_resurf_IH
>                         exp_new_bridge_IH exp_bridgereplacement_IH exp_majorbridgerehab_IH exp_minorbridg
> erehab_IH exp_bridge_IH
>                         ";

. foreach exp_var of local rur_urb_list{;
  2.                 replace `exp_var'_urban=cond(`exp_var'_urban==.,0,`exp_var'_urban);
  3.                 replace `exp_var'_rural=cond(`exp_var'_rural==.,0,`exp_var'_rural);
  4.                 gen `exp_var'_all = `exp_var'_urban + `exp_var'_rural;
  5.                 drop `exp_var'_urban `exp_var'_rural;
  6.                 };
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)
(565 real changes made)
(564 real changes made)

. *consolidate SF12a variables into nominal construction and resurfacing for pre and post 1998;
. *NB: exp_new_cons_IH_all and exp_maj_wide_IH_all are common to pre and post 1998 construction;
. gen exp_L_IH_SF12a_n_old=       exp_eng_row_IH_all + exp_new_cons_IH_all + exp_maj_wide_IH_all;

. gen exp_IRI_IH_SF12a_n_old=     exp_recons_IH_all  + exp_R3_IH_all;

.  gen exp_L_IH_SF12a_n_new=      exp_row_IH_all     + exp_eng_IH_all      + exp_new_cons_IH_all  + exp_rel
> ocation_IH_all + exp_maj_wide_IH_all;

.                         gen exp_IRI_IH_SF12a_n_new=     exp_recons_add_IH  + exp_recons_noadd_IH + exp_R3
> _min_wide_IH   + exp_R3_rehab_rest_IH  + exp_R3_resurf_IH;

. * Do the same for bridge expenditure ;
. gen exp_bridge_IH_SF12a_n_new=cond( year>1998,
>                                                                         exp_new_bridge_IH_all+exp_bridger
> eplacement_IH_all+exp_majorbridgerehab_IH_all+exp_minorbridgerehab_IH_all,.);
(931 missing values generated)

.                                                                         gen exp_bridge_IH_SF12a_n_old=con
> d( year<=1998,
>                                                                         exp_bridge_IH_all,.);
(833 missing values generated)

. *diagnostics -- should all be zero -- this test won't work for construction;
. sum exp_IRI_IH_SF12a_n_new exp_IRI_IH_SF12a_n_old if year>1998;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
exp_IRI_IH~w |        833    75901.17    142629.8          0    1142287
exp_IRI_IH~d |        833           0           0          0          0

. sum exp_IRI_IH_SF12a_n_new exp_IRI_IH_SF12a_n_old if year<=1998;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
exp_IRI_IH~w |        931           0           0          0          0
exp_IRI_IH~d |        931    47717.58    68779.22          0     560136

. *consolidate pre and post 1998 variable construction;
. gen exp_IRI_IH_SF12a_n =        cond(year>1998, exp_IRI_IH_SF12a_n_new, exp_IRI_IH_SF12a_n_old);

. gen exp_L_IH_SF12a_n =          cond(year>1998, exp_L_IH_SF12a_n_new, exp_L_IH_SF12a_n_old);

. gen exp_bridge_IH_SF12a_n =             cond(year>1998, exp_bridge_IH_SF12a_n_new, exp_bridge_IH_SF12a_n_
> old);

. *clean up -- save reloacation;
. gen temp = exp_relocation_IH_all;

. gen temp2 =exp_row_IH_all ;

. foreach exp_var of local rur_urb_list{;
  2.                 drop `exp_var'_all;
  3.                 };

.                 drop *_new *_old;

. rename temp exp_relocation_IH_all_n;

.  rename temp2 exp_row_IH_all_n ;

. *calculate total IH and SF12a maintenance;
. gen exp_IH_total_SF12_n = exp_IH_mtn_all + exp_IH_k_all;
(180 missing values generated)

. gen exp_IH_mtn_SF12a_n = exp_IH_total_SF12_n - exp_IRI_IH_SF12a_n - exp_L_IH_SF12a_n -exp_bridge_IH_SF12a
> _n;
(180 missing values generated)

. sum exp_IH_mtn_SF12a_n, d ;

                     exp_IH_mtn_SF12a_n
-------------------------------------------------------------
      Percentiles      Smallest
 1%       -34577        -796329
 5%            0        -387772
10%         4495        -242600       Obs               1,584
25%        13109        -198478       Sum of wgt.       1,584

50%     33878.59                      Mean           108119.7
                        Largest       Std. dev.      250930.4
75%     94553.93        2017193
90%       252167        2062267       Variance       6.30e+10
95%       424198        3278198       Skewness       5.866655
99%      1313969        3303381       Kurtosis         52.087

. replace exp_IH_mtn_SF12a_n= cond(exp_IH_mtn_SF12a_n<0,0,exp_IH_mtn_SF12a_n );
(27 real changes made)

. sum exp_IH_mtn_SF12a_n, d ;

                     exp_IH_mtn_SF12a_n
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%         4495              0       Obs               1,584
25%        13109              0       Sum of wgt.       1,584

50%     33878.59                      Mean           109822.3
                        Largest       Std. dev.      248973.5
75%     94553.93        2017193
90%       252167        2062267       Variance       6.20e+10
95%       424198        3278198       Skewness       6.026436
99%      1313969        3303381       Kurtosis       53.45254

. ;
. *convert to real 2010 USD 10^6;
. *NB: deflate calculated in calling program;
. rename app_IH app_IH_n;

. rename exp_IH_mtn_all exp_IH_mtn_SF12_n;

. ren rev_grand_total_mt rev_grand_total_mt_n;

. ren rev_total_h rev_total_h_n;

. ren rev_total_mt rev_total_mt_n ;

. ren rev_total_m_fuel_h rev_total_m_fuel_h_n ;

. local real_list "exp_IH_total_SF12 exp_IH_mtn_SF12a exp_IRI_IH_SF12a exp_L_IH_SF12a app_IH exp_IH_mtn_SF1
> 2 exp_relocation_IH_all 
>                                  rev_grand_total_mt rev_total_h rev_total_mt rev_total_m_fuel_h
>                                  exp_bridge_IH_SF12a exp_row_IH_all
>                                  ";

. foreach exp_var of local real_list{;
  2.                 gen `exp_var'_r=deflate*`exp_var'_n;
  3.                 drop `exp_var'_n;
  4.                 };
(180 missing values generated)
(180 missing values generated)
(900 missing values generated)
(180 missing values generated)
(996 missing values generated)
(228 missing values generated)
(996 missing values generated)
(228 missing values generated)

.         forvalues i=1(1)5{;
  2.                                 gen deflate_L`i'= 1/(ppiaco_2010_L`i'*10);
  3.                 ren L`i'FHWA_apport_LW L`i'FHWA_apport_LW_n;
  4.                 gen L`i'FHWA_apport_LW_r=deflate_L`i'*L`i'FHWA_apport_LW_n;
  5.                 drop L`i'FHWA_apport_LW_n;
  6. };
(132 missing values generated)
(180 missing values generated)
(228 missing values generated)
(276 missing values generated)
(324 missing values generated)

.                                                 *label and drop superflous expenditure data;
. label var       exp_IH_total_SF12_r     "Total IH exp SF12 real";

. label var       exp_IH_mtn_SF12_r       "Total IH maint exp SF12 real";

. label var       exp_IH_mtn_SF12a_r      "Total IH maint exp SF12a real";

.  label var      exp_IRI_IH_SF12a_r      "Total IH IRI exp SF12a real";

.  label var      exp_L_IH_SF12a_r        "Total IH L exp SF12a real";

. label var       app_IH_r                "Total IH approp real";

. label var       exp_relocation_IH_all   "Total IH exp relocation, >1998";

. label var   rev_grand_total_mt_r          "Total revenue mass transit account real [source: FE9 p2 ]";

. label var   rev_total_mt_r        "Total revenue highway and mass transit account real [source: FE9 p2 ]"
> ;

. label var   rev_total_h  "Total revenue highway account real [source: FE9 p2 ]";

. label var rev_total_m_fuel_h                     "Total Revenue motor fuel  (Highway motor fuel) [source:
>  FE9 p1 ]";

.         *drop exp_IH_k_rural-exp_subtotal_mtn_urban;
. exit;

end of do-file

. do "_cleaning_and_new_variables.do";

. 
. 
. 
. 
. # d ; 
delimiter now ;
. *label variables to mathc the names in the tables ;
. label var exp_L_IH_SF12a_r "\(I^{L}_{st} \)";

. label var  exp_IRI_IH_SF12a_r "\( Y^L\:in\:IRI \)";

. label var  exp_IH_mtn_SF12a_r "\( Y^L\: in\: Maint.\)";

. *make lagged expenditure and appropriations;
. sort state year;

. gen L1exp_L_IH_SF12a_r=cond(
>                         state[_n]==year[_n-1],
>                         year[_n-1]==year[_n]-1,
>                         exp_L_IH_SF12a_r[_n-1],.);
(1 missing value generated)

. gen L5app_IH_r=cond(
>                         state[_n]==year[_n-5],
>                         year[_n-5]==year[_n]-5,
>                         app_IH_r[_n-5],.);
(901 missing values generated)

.                         gen L1app_IH_r=cond(
>                         state[_n]==year[_n-1],
>                         year[_n-1]==year[_n]-1,
>                         app_IH_r[_n-1],.);
(900 missing values generated)

.                                                                         *calculate first differences in m
> iles and IRI;
. *local D_vars "u_iri_IH u_iri_urban u_iri_rural u_lane_miles_IH u_lane_miles_rural u_lane_miles_urban";
. local D_vars u_lane_miles_IH  u_lane_miles_rural u_lane_miles_urban u_miles_IH;

. sort state year;

. foreach varname of local D_vars{;
  2.                 gen D`varname'=cond(
>                                 state[_n]==state[_n-1]&
>                                 `varname'[_n-1]!=.&`varname'[_n]!=.&
>                                 `varname'[_n-1]!=0&`varname'[_n]!=0&
>                                 year[_n-1]==year[_n]-1,
>                                 `varname'[_n]-`varname'[_n-1],.);
  3.                                 };
(342 missing values generated)
(402 missing values generated)
(346 missing values generated)
(342 missing values generated)

.                                 *Create average width of lane miles ;
. gen u_width_IH= u_lane_miles_IH/u_miles_IH;
(293 missing values generated)

. label var u_width_IH "Avergae width of lanes";

.                                 *create expantion lanes in existing segments and new segments;
.                                 gen Du_expantion_miles_IH=cond(
>                                 state[_n]==state[_n-1]&
>                                 u_lane_miles_IH[_n-1]!=.&u_lane_miles_IH[_n]!=.&
>                                 u_miles_IH[_n-1]!=.&u_miles_IH[_n]!=.&
>                                 year[_n-1]==year[_n]-1,
>                                 Du_lane_miles_IH - Du_miles_IH*u_width_IH[_n-1],
>                                 .);
(342 missing values generated)

. *replace Du_expantion_miles_IH=0 if Du_expantion_miles_IH<0;
.                         label var Du_expantion_miles_IH "Expansion miles";

.                                 //note: The assumption to create this variable is that the new miles occu
> rs at mean width ;
> 
> gen sh_new_lm=cond(state[_n]==state[_n-1]&
>                                 u_lane_miles_IH[_n-1]!=.&u_lane_miles_IH[_n]!=.&
>                                 u_miles_IH[_n-1]!=.&u_miles_IH[_n]!=.&
>                                 year[_n-1]==year[_n]-1, Du_miles_IH*u_width_IH/Du_lane_miles_IH,.) ;
(494 missing values generated)

. *replace sh_new_lm=1 if Du_expantion_miles_IH==0 & Du_lane_miles_IH>0;
. label var sh_new_lm "Share of new lane miles in new segments";

. gen sh_exp_lm= Du_expantion_miles_IH/Du_lane_miles_IH;
(494 missing values generated)

. label var sh_exp_lm "Share of new lane miles that are expantions";

. *dropping missing d_lane_miles saves trouble later;
. * keep all years with lagge appropriations;
. * N.B.: Nothing strange here.  SF12a missing <1984;
. drop if year>2008|year<1980;
(343 observations deleted)

. drop if u_lane_miles_IH==.;
(0 observations deleted)

. drop if u_lane_miles_IH==0;
(0 observations deleted)

. drop if u_lane_miles_IH<0;
(0 observations deleted)

. *drop DC;
. drop if state==11;
(29 observations deleted)

. * time, for estimating trends;
. gen time =year-1984;

. gen time2 =time^2;

. gen time3 =time^3;

. label var time2 "\(time^2\)" ;

. label var time3 "\(time^3\)" ;

. *TIME TREND DUMMIES;
. gen     periods=1 if  year>=1984&year<=1989;
(1,104 missing values generated)

. replace periods=2 if  year>=1990&year<=1994;
(240 real changes made)

. replace periods=3 if  year>=1995&year<=1999;
(240 real changes made)

. replace periods=4 if  year>=2000&year<=2004;
(240 real changes made)

. replace periods=5 if  year>=2005&year<=2008;
(192 real changes made)

. tab year periods, m ;

           |                              periods
 Book year |         1          2          3          4          5          . |     Total
-----------+------------------------------------------------------------------+----------
      1980 |         0          0          0          0          0         48 |        48 
      1981 |         0          0          0          0          0         48 |        48 
      1982 |         0          0          0          0          0         48 |        48 
      1983 |         0          0          0          0          0         48 |        48 
      1984 |        48          0          0          0          0          0 |        48 
      1985 |        48          0          0          0          0          0 |        48 
      1986 |        48          0          0          0          0          0 |        48 
      1987 |        48          0          0          0          0          0 |        48 
      1988 |        48          0          0          0          0          0 |        48 
      1989 |        48          0          0          0          0          0 |        48 
      1990 |         0         48          0          0          0          0 |        48 
      1991 |         0         48          0          0          0          0 |        48 
      1992 |         0         48          0          0          0          0 |        48 
      1993 |         0         48          0          0          0          0 |        48 
      1994 |         0         48          0          0          0          0 |        48 
      1995 |         0          0         48          0          0          0 |        48 
      1996 |         0          0         48          0          0          0 |        48 
      1997 |         0          0         48          0          0          0 |        48 
      1998 |         0          0         48          0          0          0 |        48 
      1999 |         0          0         48          0          0          0 |        48 
      2000 |         0          0          0         48          0          0 |        48 
      2001 |         0          0          0         48          0          0 |        48 
      2002 |         0          0          0         48          0          0 |        48 
      2003 |         0          0          0         48          0          0 |        48 
      2004 |         0          0          0         48          0          0 |        48 
      2005 |         0          0          0          0         48          0 |        48 
      2006 |         0          0          0          0         48          0 |        48 
      2007 |         0          0          0          0         48          0 |        48 
      2008 |         0          0          0          0         48          0 |        48 
-----------+------------------------------------------------------------------+----------
     Total |       288        240        240        240        192        192 |     1,392 

. label define periods 1 "1984-1989"
>                                         2 "1990-1994"
>                                         3 "1995-1999"
>                                         4 "2000-2004"
>                                         5 "2005-2008";

. label values periods periods;

. # d cr ;
delimiter now cr
. 
. 
end of do-file

. xtset state year;

Panel variable: state (strongly balanced)
 Time variable: year, 1980 to 2008
         Delta: 1 year

. gen Dmiles=d.u_miles_IH ;
(48 missing values generated)

. gen no_exp=cond(exp_L_IH_SF12a_r==. | exp_L_IH_SF12a_r==. | exp_L_IH_SF12a_r<0,1,0);

. *Defining macro variables;
.  global lm_var u_lane_miles_IH u_lane_miles_rural u_lane_miles_urban u_miles_IH
>                                  s_lane_miles_IH s_lane_miles_rural_IH s_lane_miles_urban_IH s_lane_miles
> _rig_IH
>                                  ;

.                                  gen lm_IH_h2O=                 u_lane_miles_IH*sh_h20_10m_s;

.  gen lm_IH_urb=                 u_lane_miles_IH*sh_urb_10m_s;

.  gen lm_IH_elev=        u_lane_miles_IH*sh_elev_10m_s;

.  gen lm_IH_sd_elev=     u_lane_miles_IH*sh_sd_elev_10m_s ;

. gen lm_IH_temp=         u_lane_miles_IH*sh_temp_10m_s;

.  gen lm_IH_precip=      u_lane_miles_IH*sh_precip_10m_s;

.  gen lm_IH_sh_new_lm  =         u_lane_miles_IH*sh_new_lm;
(182 missing values generated)

. gen lm_IH_unionization=         u_lane_miles_IH*unionization;
(960 missing values generated)

. gen lm_IHunionization_Mem_Priv_Cons=    u_lane_miles_IH*unionization_Cov_Priv_Cons ;
(144 missing values generated)

. gen lm_IHunionization_Mem_Total=        u_lane_miles_IH*unionization_Cov_Total ;
(144 missing values generated)

. gen lm_IH_grade = u_lane_miles_IH*s_average_grade_seg_IH ;
(406 missing values generated)

. format lm_IH_grade  %3.2fc;

. gen lm_IH_new=Du_lane_miles_IH*sh_new_lm;
(182 missing values generated)

. *replace lm_IH_new=. if year==1984;
. global comp_var lm_IH_h2O    lm_IH_urb    lm_IH_elev    lm_IH_temp    lm_IH_precip lm_IH_sd_elev lm_IH_gr
> ade lm_IH_new  Dmiles
>                                 sh_h20_10m_s sh_urb_10m_s sh_elev_10m_s sh_temp_10m_s sh_precip_10m_s sh_
> sd_elev_10m_s 
>                                 lm_IH_unionization  lm_IHunionization_Mem_Priv_Cons  lm_IHunionization_Me
> m_Total;

. gen u_inches_IH=        u_iri_IH*u_lane_miles_IH;
(2 missing values generated)

. gen s_inches_IH=        s_iri_IH*s_lane_miles_IH;
(429 missing values generated)

. drop u_iri_IH s_iri_IH s_trucks_av_IH;

. global exp_var   exp_L_IH_SF12a_r exp_IRI_IH_SF12a_r exp_IH_mtn_SF12a_r exp_IH_mtn_SF12_r
>                                  exp_relocation_IH_all_r 
>                                 s_vmt_IH u_vmt_IH s_vmt_trucks_av_IH s_vmt_trucks_peak_IH  u_inches_IH s_
> inches_IH
>                                 s_vmt_NHS ;

.         global rev_var rev_grand_total_mt_r rev_total_h_r rev_total_mt_r rev_total_m_fuel_h_r;

.                                 *---------------------------------------------------;
. * - Collapse (year) ;
. *---------------------------------------------------;
. *u_lane_miles_IH
> *conversion factor to get to 10^6 2010 dollars;
.                 sort year;

. collapse (mean) DGS10_r asphalt_price Surf_BituminousconcreteAv_ctn10
> 
>                  (sum) ${lm_var}
>                             ${exp_var}
>                            ${rev_var}
>                      , by(year);

. gen u_aadt_IH=          (u_vmt_IH/u_lane_miles_IH)/365;

. gen s_aadt_IH=          (s_vmt_IH/s_lane_miles_IH)/365;
(8 missing values generated)

. gen s_aadt_trucks_av_IH=        s_vmt_trucks_av_IH /s_lane_miles_IH;
(8 missing values generated)

. gen s_aadt_trucks_peak_IH=      s_vmt_trucks_peak_IH/s_lane_miles_IH;
(8 missing values generated)

. gen s_iri_IHnat =       s_inches_IH/s_lane_miles_IH;
(8 missing values generated)

. gen u_iri_IHnat =       u_inches_IH/u_lane_miles_IH;

. label var exp_L_IH_SF12a_r              "Construction USD2010";

. label var exp_IRI_IH_SF12a_r    "Resurfacing USD2010";

. label var exp_IH_mtn_SF12a_r    "Maintenance USD2010";

. label var u_lane_miles_IH               "Lane Miles IH, HPMS Universe";

. label var s_lane_miles_IH               "Lane Miles IH, HPMS Sample";

.         label var u_miles_IH            "Miles IH, HPMS Universe";

. label var u_aadt_IH                             "AADT IH, HPMS Universe";

.         label var s_aadt_IH                             "AADT IH, HPMS Sample";

.         label var s_iri_IHnat                   "IRI IH, HPMS Sample";

. label var u_iri_IHnat                   "IRI IH, HPMS Universe";

.   label var u_vmt_IH "VMT IH, Universe";

. label var s_aadt_trucks_av_IH "Trucks";

. label var  s_aadt_trucks_peak_IH  "Trucks peak hours";

. label var rev_total_mt_r "Total revenue highway and mass transit account USD2010 [source: FE9 p2 ]";

. label var rev_total_m_fuel_h_r   "Total Revenue motor fuel (Highway motor fuel)  USD2010 [source: FE9 p1 
> ]";

. label var rev_total_h_r  "Total revenue  USD2010 [source: FE9 p1]" ;

. label var  rev_grand_total_mt_r "Total revenue mass transit account USD2010 [source: FE9 p2 ]" ;

. label var asphalt_price "Asphault prices";

. label var Surf_BituminousconcreteAv_ctn10 "Asphault Prices";

. drop asphalt_price u_lane_miles_rural u_lane_miles_urban s_lane_miles_rural_IH s_lane_miles_urban_IH s_la
> ne_miles_rig_IH exp_IH_mtn_SF12_r exp_relocation_IH_all_r  u_inches_IH s_inches_IH ;

. *ADD COEFFECIENTS ;
. merge 1:1 year  using "../intermediate_data/construction_betas_1.dta", nogen ;

    Result                      Number of obs
    -----------------------------------------
    Not matched                             4
        from master                         4  
        from using                          0  

    Matched                                25  
    -----------------------------------------

. ren beta P_const_beta;

. ren se P_const_se;

. label var P_const_beta "Coefficients Construction";

. label var P_const_se "SE Construction";

. drop dummy up down;

. merge 1:1 year  using "../intermediate_data/maintF12a_betas_1.dta", nogen ;

    Result                      Number of obs
    -----------------------------------------
    Not matched                             4
        from master                         4  
        from using                          0  

    Matched                                25  
    -----------------------------------------

. ren beta P_maint_beta;

. ren se P_maint_se;

. label var P_maint_beta "Coefficient Maintenance";

. label var P_maint_se "SE Maintenance";

. drop dummy up down;

. merge 1:1 year  using "../intermediate_data/resurf_betas_1.dta", nogen ;

    Result                      Number of obs
    -----------------------------------------
    Not matched                            12
        from master                        12  
        from using                          0  

    Matched                                17  
    -----------------------------------------

. ren beta P_resurf_beta;

. ren se P_resurf_se;

. label var P_resurf_beta "Coefficient Resurfacing" ;

. label var P_resurf_se "SE Resurfacing" ;

. drop dummy up down;

. replace s_iri_IHnat=. if year<1990;
(2 real changes made, 2 to missing)

. replace u_iri_IHnat=. if year<1993;
(13 real changes made, 13 to missing)

. foreach var in exp_L_IH_SF12a_r exp_IRI_IH_SF12a_r exp_IH_mtn_SF12a_r{;
  2.         replace `var'=. if year <1984;
  3. };
(4 real changes made, 4 to missing)
(4 real changes made, 4 to missing)
(4 real changes made, 4 to missing)

. foreach var in rev_grand_total_mt_r rev_total_h_r rev_total_mt_r rev_total_m_fuel_h_r s_lane_miles_IH{;
  2.         replace `var'=. if `var'==0;
  3. };
(16 real changes made, 16 to missing)
(16 real changes made, 16 to missing)
(19 real changes made, 19 to missing)
(0 real changes made)
(8 real changes made, 8 to missing)

. **Save;
. save "../intermediate_data/national_vars" , replace ;
file ../intermediate_data/national_vars.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/juanpablouribetrujillo/My Drive (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analys
> is/../logs/create_national_vars.log
  log type:  text
 closed on:  24 Jun 2024, 22:26:49
-----------------------------------------------------------------------------------------------------------
